<% layout('/layouts/default.html', {title: '报关通知查询', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text('报关通知详情')}
                <% if (hasPermi('financial:declarationnotice:tdeclarationNotice:edit')){ %>
                    <button type="button" class="btn btn-primary" id="editView">${text('编辑单据')}</button>
                <% } %>
				<% if( tdeclarationNotice.isNotice != "1"){%>
				<button type="button" class="btn btn-primary" id="btn_notice" >${text('通知')}</button>
				<% } %>
                <% if (hasPermi('logistics:customsdeclaration:customsDeclaration:edit') && tdeclarationNotice.customsDeclarationCode == ""){ %>
                    <button type="button" class="btn btn-primary" id="createDeclaration">${text('报关')}</button>
                <% } %>
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${tdeclarationNotice}" action="${ctx}/financial/declarationnotice/tdeclarationNotice/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="customsDeclarationNoticeId" id="customsDeclarationNoticeId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="customsDeclarationNoticeCode" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				<#form:hidden path="isNotice"/>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('客户')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="customerId" items="${listCustomer}" disabled="true"
								itemLabel="customerName" itemValue="customerId" required="true" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="serviceOrderId" readonly="true" placeholder="自动编号" maxlength="100" disabled="true" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('报关行')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="customsBroker" items="${listSupplier}"
								itemLabel="supplierName" itemValue="supplierId" required="true" blankOption="true" disabled="true" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('提单编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="ladingBillId" readonly="true" placeholder="自动编号" maxlength="100" disabled="true" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('报关单')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="customsDeclarationCode" items="${customsDeclarationList}"
								itemLabel="customsDeclarationCode" itemValue="customsDeclarationId" required="true" blankOption="true" disabled="true" class="form-control" />

							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('目的港')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="toPort" dictType="erp_harbor_list" blankOption="true" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('外贸合同号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="foreignTradeContractNumber" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('采购委托书号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="purchaseCommissionNumber" maxlength="100" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('通知日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="date" readonly="true" maxlength="20" class="form-control" disabled="true"
									dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('已全部上传')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:checkbox path="allUploadFlag" dictType="sys_yes_no" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('图片上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${tdeclarationNotice.id}" bizType="tdeclarationNotice_image"
									uploadType="image" class="" readonly="true" preview="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${tdeclarationNotice.id}" bizType="tdeclarationNotice_file"
									uploadType="all" class="" readonly="true" preview="true"/>
							</div>
						</div>
					</div>
				</div>
				<h4 class="form-unit">${text('报关通知清单')}</h4>
				<div class="ml10 mr10">
					<table id="tdeclarationNoticeListDataGrid"></table>
				</div>
				<h4 class="form-unit">${text('报关通知明细')}</h4>
				<div class="ml10 mr10">
					<table id="tdeclarationNoticeDetailDataGrid"></table>
				</div>
				<div class="form-unit">${text('系统信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="createDate" class="form-control" disabled="true"
								dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<!--<#form:input path="createBy" class="form-control" disabled="true"/>-->
								<#form:select path="createBy" items="${listUser}" disabled="true"
								itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
								dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<!--<#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>-->
								<#form:select path="updateBy" items="${listUser}" disabled="true"
								itemLabel="userName" itemValue="userCode"  blankOption="true" class="form-control"/>
							</div>
						</div>
					</div>
				</div>

			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">

						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化报关通知清单DataGrid对象
$("#tdeclarationNoticeListDataGrid").dataGrid({

	data: ${toJson(tdeclarationNotice.tdeclarationNoticeListList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度

	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'customsDeclarationNoticeListId', editable:true, hidden:true},
		{header:'${text("资料名称")}', name:'data', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100','readonly':'true', 'class':'form-control'}},
		{header:'${text("报关通知ID")}', name:'customsDeclarationNoticeId.customsDeclarationNoticeId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],

	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	editGridInitRowNum: 1,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#tdeclarationNoticeListDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {customsDeclarationNoticeListId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

	// 编辑表格的提交数据参数
	editGridInputFormListName: 'tdeclarationNoticeListList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,customsDeclarationNoticeListId,data,customsDeclarationNoticeId.customsDeclarationNoticeId,', // 提交数据列表的属性字段

	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});
//初始化报关通知明细DataGrid对象
$("#tdeclarationNoticeDetailDataGrid").dataGrid({

	data: ${toJson(tdeclarationNotice.tdeclarationNoticeDetailList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度

	// 设置数据表格列
	columnModel: [
		{header:'状态', name:'status', editable:true, hidden:true},
		{header:'主键', name:'customsDeclarationNoticeDetailId', editable:true, hidden:true},
		{header:'${text("车架号")}', name:'frameNumber', width:100,editable:false,edittype:'text', editoptions:{'maxlength':'100','readonly':'true', 'class':'form-control'}},
		{header:'${text("行号")}', name:'rowNumber', width:100,editable:false,edittype:'text', editoptions:{'maxlength':'100','readonly':'true', 'class':'form-control'}},
		{header:'${text("车辆")}', name:'carId', width:100,editable:false,edittype:'text', editoptions:{'maxlength':'100','readonly':'true', 'class':'form-control'}},
		{header:'${text("品牌")}', name:'brand', index:'a.brand', width:150, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('car_pinpai')}, val, '${text("未知")}', true);
			}},
		{header:'${text("版型")}', name:'area', index:'a.brand', width:150, align:"center", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('car_quyu')}, val, '${text("未知")}', true);
			}},
		{header:'${text("车型")}', name:'model', width:150, editable:false, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}},
		{header:'${text("报关通知ID")}', name:'customsDeclarationNoticeId.customsDeclarationNoticeId', editable:true, hidden:true},
		{header:'${text("操作")}', name:'actions', hidden: true}
	],

	// 编辑表格参数
	editGrid: true,				// 是否是编辑表格
	editGridInitRowNum: 1,		// 编辑表格的初始化新增行数
	editGridAddRowBtn: $('#tdeclarationNoticeDetailDataGridAddRowBtn'),	// 子表增行按钮
	editGridAddRowInitData: {customsDeclarationNoticeDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

	// 编辑表格的提交数据参数
	editGridInputFormListName: 'tdeclarationNoticeDetailList', // 提交的数据列表名
	editGridInputFormListAttrs: 'status,customsDeclarationNoticeDetailId,frameNumber,carId,brand,area,model,customsDeclarationNoticeId.customsDeclarationNoticeId,rowNumber', // 提交数据列表的属性字段

	// 加载成功后执行事件
	ajaxSuccess: function(data){

	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
$("#btn_notice").click(function() {
	var customsDeclarationNoticeId = $("#customsDeclarationNoticeId").val();
	js.confirm("确认要发送报关通知吗？", '${ctx}/financial/declarationnotice/tdeclarationNotice/notice?customsDeclarationNoticeId=' + customsDeclarationNoticeId, null, function (data) {
		js.alert("发送通知成功！");
		history.go(0);
	}, 'json', true, '正在发送...');
});
$("#btn_declaration").click(function(){
	var customsDeclarationNoticeId = $("#customsDeclarationNoticeId").val();
	var URL = '' + customsDeclarationNoticeId;
	window.location.href =URL;
});

$("#editView").click(function () {
    var id = $("#customsDeclarationNoticeId").val();
    var URL = '${ctx}/financial/declarationnotice/tdeclarationNotice/form?customsDeclarationNoticeId=' + id;
    window.location.href =URL;
});
$("#createDeclaration").click(function () {
    var id = $("#customsDeclarationNoticeId").val();
    var URL = '${ctx}/logistics/customsdeclaration/customsDeclaration/createFromDeclaration?customsDeclarationNoticeId=' + id;
    window.location.href =URL;
});

</script>
